package entity;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;

import common.BaseModelObject;

@Entity
public abstract class Event extends BaseModelObject {

	private long time;
	@ManyToOne
	private Equipment equipment;

	public Event(Equipment equipment) {
		this.time = System.currentTimeMillis();
		this.equipment = equipment;
		if(equipment!=null){
			equipment.getEvents().add(this);
		}
		changeEquipmentState();
	}

	protected abstract void changeEquipmentState();

	public long getTime() {
		return time;
	}

	public void setTime(long time) {
		this.time = time;
	}

	public Equipment getEquipment() {
		return this.equipment;
	}

	public void setEquipment(Equipment equipment) {
		this.equipment = equipment;
	}

}